import request from '@/utils/request'

// 创建问题
export function createQuestion(data) {
  return request({
    url: '/question/create',
    method: 'post',
    data
  })
}

// 更新问题
export function updateQuestion(data) {
  return request({
    url: '/question/update',
    method: 'put',
    data
  })
}

// 删除问题
export function deleteQuestion(questionId) {
  return request({
    url: `/question/${questionId}`,
    method: 'delete'
  })
}

// 获取问题详情
export function getQuestionDetail(questionId) {
  return request({
    url: `/question/${questionId}`,
    method: 'get'
  })
}

// 分页查询问题列表
export function getQuestionList(data) {
  return request({
    url: '/question/list',
    method: 'post',
    data
  })
}

// 关注/取消关注问题
export function toggleFollowQuestion(questionId) {
  return request({
    url: `/question/${questionId}/follow`,
    method: 'post'
  })
}

// 点赞/取消点赞问题
export function toggleLikeQuestion(questionId) {
  return request({
    url: `/question/${questionId}/like`,
    method: 'post'
  })
}

// 增加问题浏览数
export function incrementViewCount(questionId) {
  return request({
    url: `/question/${questionId}/view`,
    method: 'post'
  })
}
